package es.xpt.ysf.commons.jaas;

import java.util.List;
import java.util.TreeSet;

import javax.ejb.Local;

import es.xpt.ysf.YSFException;
import es.xpt.ysf.jaas.YSFPrincipal;
import es.xpt.ysf.model.Item;

@Local
public interface  JaasSession {
	
	/**
	 * @param entity
	 * @param entityId
	 * @return
	 * @throws YSFException
	 */
	public List<YSFPrincipal> getEntityUsers(String entity, String entityId)
			throws YSFException;
	/**
	 * 
	 * @param entity
	 * @return
	 * @throws YSFException
	 */
	public List<YSFPrincipal> getAllEntityUsers(String entity)
	throws YSFException;
	

	/**
	 * @param principal
	 * @param pass
	 * @param entityId
	 * @param entity
	 * @throws YSFException
	 */
	public void insertUser(YSFPrincipal principal, String pass, List<Item> roles,
			String entityId, String entity) throws YSFException;

	/**
	 * @param entityId
	 * @param entity
	 * @param principal
	 * @throws YSFException
	 */
	public void deleteUser(String entityId, String entity, String principal)
			throws YSFException;


	/**
	 * @param principal
	 * @throws YSFException
	 */
	public void updateUser(YSFPrincipal principal, String pass, List<Item> roles) throws YSFException;

	
	/**
	 * @return
	 * @throws YSFException
	 */
	public List<Item> getRoles() throws YSFException;
	
	/**
	 * @param role
	 * @return
	 * @throws YSFException
	 */
	public TreeSet<String> getRolePrivileges(String role) throws YSFException;
	
	/**
	 * @param role
	 * @throws YSFException
	 */
	public void deleteRole(String role) throws YSFException;
	
	/**
	 * @param role
	 * @throws YSFException
	 */
	public void insertRole(Item role) throws YSFException;
	
	/**
	 * @param role
	 * @throws YSFException
	 */
	public void updateRole(Item role) throws YSFException;
	
	public List<Item> getUserRoles(String principal, String crendential) throws YSFException;
	
	public void removePrivilege(String role, String privilege)
	throws YSFException;
public void removePrivileges(String role, String[] privileges)
	throws YSFException;
public void insertPrivileges(String role, String[] privileges)
	throws YSFException;
public void insertPrivilege(String role, String privilege)
	throws YSFException;
}
